{{extend '../layout.html'}}
{{block 'body'}}
<div class="container">
  <form action="/users/addUser" method="post">
    <div class="form-group">
      <label for="userName">用户名</label>
      <input type="text" class="form-control" id="userName" name="userName">
    </div>
    <div class="form-group">
      <label for="password">Password</label>
      <input type="password" class="form-control" name="password" id="password" placeholder="Password">
    </div>
    <div class="form-group">
      <label for="showName">昵称</label>
      <input type="showName" class="form-control" name="showName" id="showName" placeholder="昵称">
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
    <button id="cancel" type="button" class="btn btn-default">Cancel</button>
  </form>
</div>
<script type="text/javascript">
      $('#cancel').click(function(){
          location.href = "/";
      });
      $('#sub').click(()=>{
        $.ajax({
          url:'/users/reg',
          type:'post',
          dataType:'JSON',
          success:res=>{
            if(res.err==1){
              swal('',res.msg,'error');
              return 
            }
            location.href = "/home";
          }
        })
      })
</script>
{{/block}}